import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
const state = {
	telnum: '',
	uid: 0,
	userinfo: '',
	appinfo: {},
};
const getters = {
	guid(state) {
		return state.uid
	},
	gtelnum(state) {
		return state.telnum
	},
	guserinfo(state) {
		return state.userinfo
	},
	gappinfo(state) {
		return state.appinfo
	}
};
const mutations = {
	suid(state, value) {
		state.uid = value;
	},
	stelnum(state, value) {
		state.telnum = value;
	},
	suserinfo(state, value) {
		state.userinfo = value;
	},
	sappinfo(state, value) {
		state.appinfo = value;
	}
};
const actions = {
	setuid(context, value) {
		context.commit('suid', value);
	},
	settelnum(context, value) {
		context.commit('stelnum', value);
	},
	setuserinfo(context, value) {
		context.commit('suserinfo', value);
	}
};
const store = new Vuex.Store({
	state,
	getters,
	mutations,
	actions,
});
export default store;

// import Vue from 'vue'
// import Vuex from 'vuex'
// 
// Vue.use(Vuex)
// 
// const actions = {}
// const mutations = {
//     handleUseinfo: (state, user_info) => {
//         state.user_info = user_info
//             // 把登录的用户的名保存到localStorage中，防止页面刷新，导致vuex重新启动，用户名就成为初始值（初始值为空）的情况
//         localStorage.setItem('user_info',user_info)
//     }
// }
// const state = {
//     user_info: '' || localStorage.getItem('user_info')
// }
// // getters 只会依赖 state 中的成员去更新
// const getters = {
//     userInfo: (state) => state.user_info
// }
// 
// const store = new Vuex.Store({
//     actions,
//     mutations,
//     state,
//     getters
// })
// 
// export default store